<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<link rel="stylesheet" type="text/css" href="<?php echo $this->_webroot('skin/css/admin.css'); ?>">
<link rel="stylesheet" type="text/css" href="<?php echo $this->_webroot('skin/css/main.css'); ?>">

<style>
td span {color:red;}
.green {color:green;}
.red {color:red;}
</style>
</head>
<body>
<input type="hidden" id="update_right" value="1" ></input>
<div id="maincontent">
<psp:tags     htmlname='messagebox'  iconname='messagebox' />
	<div class="wrap">
    <div class="crumbs">当前位置 &gt;&gt; 用户管理 &gt;&gt; 会员基本信息修改</div>
        <hr />
	<div class="infobox">
    <h3><span class="left">会员基本信息修改</span> <span style="margin-right:15px;" class="right"><a style="float:right;" href="<?php echo $this->_url('admin/user/index');?>">会员列表</a></span></h3>
    <div class="content2">
		
		<form action="<?php echo $this->_url('admin/user/edit/'.$user_info['id']);?>" method="post">
		<table class="form-table">
		  <tbody>
			<tr>
				<td style="width:60px;">会员名称：</td>
				<td><?php echo $user_info['username']; ?></td>
			</tr>
			<tr>
				<td>会员邮箱：</td>
				<td><input class="small-text" type="text" name="data[email]" value="<?php echo $user_info['email']; ?>" /> <span id="user_email_message"></span></td>
			</tr>
			<tr>
				<td>会员级别：</td>
				<td><select name="data[rank_id]">
				<?php foreach($userrank as $value) { ?>
					<option value="<?php echo $value['id'];?>" <?php if($value['id']==$user_info['rank_id']) echo "selected"; ?>><?php echo $value['rank_name']; ?></option>
				<?php }?>
				</select></td>
			</tr>
			<tr>
				<td>权限级别：</td>
				<td><select name="data[groupid]">
					<option value="2" <?php if('2'==$user_info['groupid']) echo "selected"; ?>>普通会员</option>
					<option value="3" <?php if('3'==$user_info['groupid']) echo "selected"; ?>>VIP会员</option>	
					<option value="4" <?php if('4'==$user_info['groupid']) echo "selected"; ?>>系统管理员</option>						
				</select></td>
			</tr>			
			<tr>
				<td>密 码：</td>
				<td><input class="small-text" type="password" name="data[password]" /> 不作修改请留空</td>
			</tr>
			<tr>
				<td>邮箱验证：</td>
				<td><input type="checkbox" name="data[isemail]" value="1" <?php if($user_info['isemail']) {echo 'checked';} ?> />通过验证</td>
			</tr>
				<tr>
		<td class="right">锁定状态：</td>
		<td><input type="checkbox" name="data[locked]" value="1" <?php if($user_info['locked']) {echo 'checked';} ?> />锁定</td>
	</tr>
			<tr>
				<input type="hidden" name="data[user_id]" value="<?php echo $user_info['id'];?>">
				<td colspan="2"><span class="button-container"><input class="regular-button" type="submit" name="submit" value="修改会员信息" /></span></td>
			</tr>
		  </tbody>
		</table>
		</form>		
		
		
	  </div>
	 </div>
	</div>
</div>
<script language="JavaScript" src="<?php echo $this->_webroot('servtools/ajax_client/ajax.js'); ?>"></script>
<script>
var user_email_value = '<?php echo $user_info['email']; ?>';
var user_email = document.getElementsByName("data[email]")[0];
var user_email_message = document.getElementById("user_email_message");
var submit = document.getElementsByName("submit")[0];
var user_email_reg = /^[0-9a-zA-Z_\-\.]+@[0-9a-zA-Z_\-]+(\.[0-9a-zA-Z_\-]+)*$/;
user_email.onblur = function(){
	if(user_email.value=='') {
		user_email_message.innerHTML = '会员邮箱不能为空!';
		submit.disabled = true;
	} else if(!user_email.value.match(user_email_reg)) {
		user_email_message.innerHTML = '填写的会员邮箱格式不正确!';
		submit.disabled = true;
	} else if(user_email.value!=user_email_value) {
		user_email_message.innerHTML = '正在检测会员邮箱是否可用!';
		submit.disabled = true;
		ajax("<?php echo $this->_url('admin/user/checkuseremail/');?>","POST","v="+user_email.value,function(data){
			if(data==1) {
				user_email_message.innerHTML = '';
				submit.disabled = false;
			} else {
				user_email_message.innerHTML = '很抱歉，此会员邮箱已被使用！';
				submit.disabled = true;
			}
		});
	} else {
		submit.disabled = false;
	}
}
</script>
</body>
</html>